﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TongHopBookFlightDAO.DAO
{
    public class DiaDiemDAO
    {
        public static DiaDiem SelectByID(int ID)
        {
            DiaDiem diaDiem = null;
            try
            {
                BookFlightDataContext context = new BookFlightDataContext();
                diaDiem = context.DiaDiems.Where(p => p.DiaDiemID == ID).FirstOrDefault();

            }
            catch { }
            return diaDiem;
        }

        /// <summary>
        /// Lấy địa điểm dựa vào tên địa điểm 
        /// </summary>
        /// <param name="maDiaDiem">Mã địa điểm</param>
        public static DiaDiem SelectByCode(string maDiaDiem)
        {
            DiaDiem diaDiem = null;
            try
            {
                BookFlightDataContext context = new BookFlightDataContext();
                diaDiem = context.DiaDiems.Where(p => p.MaDiaDiem.Trim() == maDiaDiem.Trim()).FirstOrDefault();
               
            }
            catch { }
            return diaDiem;
        }

        public static List<DiaDiem> GetAll()
        {
            List<DiaDiem> listObjResults = new List<DiaDiem>();
            try
            {
                BookFlightDataContext context = new BookFlightDataContext();
                listObjResults = context.DiaDiems.ToList<DiaDiem>();
            }
            catch { }
            return listObjResults;
        }
    }
}
